#!/usr/bin/env python
# -*- encoding: utf-8 -*-

"""
   @File    :   request_tools.py
   @Create  :   2021/04/08 13:58:42
   @Author  :   Xue Chengeng
   @Update  :   2021/04/08
   @License :   (C)Copyright 2014-2021 SmartAHC All Rights Reserved 
   @Desc    :   Coding Below
"""

import requests


def server_requests(method, url, data=None, files=None, multipart=False, root_path=None, headers=None):
    upper_method = method.upper()
    absolute_url = root_path + url
    if multipart:
        response = requests.request(method=upper_method, url=absolute_url, data=data, files=files, headers=headers)
    else:
        response = requests.request(method=upper_method, url=absolute_url, json=data, headers=headers)
    return response

